package com.example.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@Api("拦截器测试")
public class MyInterceptorController {

    @ResponseBody
    @GetMapping("/true")
    @ApiOperation("ok方法，存入用户session")
    public String ok(HttpServletRequest request){
        request.getSession().setAttribute("name","qzy");
        return "true";
    }

    @ResponseBody
    @GetMapping("/false")
    @ApiOperation("no方法，存入用户错误的session")
    public String no(HttpServletRequest request){
        request.getSession().setAttribute("name","qzy1");
        return "true";
    }

    @ResponseBody
    @ApiOperation("pre方法，测试拦截器")
    @GetMapping("/pre")
    public String pre(){
        return "pre-true";
    }

}
